package com.shadow.mall.fulfill.remote.dubbo;


import com.shadow.mall.common.core.JsonResult;
import com.shadow.mall.fulfill.exception.FulfillBizException;
import com.shadow.mall.fulfill.remote.TmsService;
import com.shadow.mall.tms.api.TmsApi;
import com.shadow.mall.tms.domain.SendOutDTO;
import com.shadow.mall.tms.domain.SendOutRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * tms服务远程接口
 *
 * @version 1.0
 */
@Component
public class TmsRemote {


//    @Autowired
//    private TmsApi tmsApi;

    @Autowired
    TmsService tmsService;


    /**
     * 发货
     */
    public SendOutDTO sendOut(SendOutRequest request) {
        JsonResult<SendOutDTO> jsonResult = tmsService.sendOut(request);
        if (!jsonResult.getSuccess()) {
            throw new FulfillBizException(jsonResult.getErrorCode(), jsonResult.getErrorMessage());
        }
        return jsonResult.getData();
    }

    /**
     * 取消发货
     */
    public void cancelSendOut(String orderId) {
        JsonResult<Boolean> jsonResult = tmsService.cancelSendOut(orderId);
        if (!jsonResult.getSuccess()) {
            throw new FulfillBizException(jsonResult.getErrorCode(), jsonResult.getErrorMessage());
        }
    }

}
